package com.qf.controller;

import com.qf.pojo.entity.Goods;
import com.qf.pojo.entity.GoodsClassify;
import com.qf.pojo.entity.StoreInfo;
import com.qf.pojo.resp.BaseResp;
import com.qf.pojo.resp.GoodsResp;
import com.qf.pojo.vo.GoodsVo;
import com.qf.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
@Api(tags = "商品管理")
public class GoodsController {
    @Autowired
    GoodsService goodsService;
    //根据店铺id查询该店铺下所有商品,返回商品分类里面商品集合
    @PostMapping("/findAll")
    @ApiOperation(value = "根据店铺id查询该店铺下所有商品,返回商品分类里面商品集合")
    public BaseResp findAll(@RequestBody StoreInfo storeInfo){
        return goodsService.findAll(storeInfo.getId());
    }
    //修改商品,和商品分类,以及中间表的关系
    @PostMapping("/updateOne")
    @ApiOperation(value = "修改商品,和商品分类,以及中间表的关系")
    public  BaseResp updateOne(@RequestBody GoodsResp goodsResp){

        return goodsService.updateOne(goodsResp);

    }
    //查询所有商品分类,为下拉框准备
    @PostMapping("/allType")
    @ApiOperation(value = "查询所有商品分类,为下拉框准备")
    public  BaseResp allType(@RequestBody StoreInfo storeInfo){

        return goodsService.allType(storeInfo.getId());

    }
    //添加商品,和商品分类,以及中间表的关系
    @PostMapping("/addOne")
    @ApiOperation(value = "添加商品,和商品分类,以及中间表的关系")
    public BaseResp addOne(@RequestBody GoodsResp goodsResp){
        return goodsService.addOne(goodsResp);
    }


    //删除商品,和商品分类,以及中间表的关系
    @PostMapping("/deleteOne")
    @ApiOperation(value = "删除商品,和商品分类,以及中间表的关系")
    public BaseResp deleteOne(@RequestBody GoodsResp goodsResp){
        return goodsService.deleteOne(goodsResp);
    }


}
